﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Web.Script.Services;
namespace MediaMonitor
{
    [System.Web.Script.Services.ScriptService]
    public partial class Default : Adex.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }



        [WebMethod]
        [ScriptMethod]
        public static string[] GetData(string prefixText, int count)
        {
            if (count == 0) { count = 10; }
            List<string> items = new List<string>(count);

            DataTable dt = Adex.Brand.Query().ExecuteDataSet().Tables[0];

            DataRow[] drs = dt.Select("BrandName LIKE '%" + prefixText + "%'");

            int counter = 0;
            foreach (DataRow dr in drs)
            {
                items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(dr["BrandName"].ToString(), dr["BrandCode"].ToString()));


                if (++counter >= count) { break; }
            }

            return items.ToArray();
        }

    }
}